﻿using System;
using System.Reflection;

namespace RoketSolutions.SP2010.Infrostructure.UI.Ajax.Controllers
{
    internal class ActionMethodSelector
    {        
        public ActionMethodSelector(ControllerDescriptor controllerDescriptor)
        {
            ControllerDescriptor = controllerDescriptor;
        }

        public MethodInfo FindActionMethod(String actionName)
        {
            if (ControllerDescriptor != null)
                return ControllerDescriptor.Controller.GetType().GetMethod(actionName, BindingFlags.Instance | BindingFlags.Public);
            return null;
        }

        public ControllerDescriptor ControllerDescriptor
        {
            get; 
            private set;
        }
    }
}
